<?php

namespace app\admin\controller;

use controller\BasicAdmin;
use app\admin\service\NodeService;
use library\tools\Data;
use think\Console;
use think\Db;
use think\exception\HttpResponseException;

/**
 * 系统公共操作
 * Class Index
 * @package app\admin\controller
 */
class Video extends BasicAdmin
{

    public $table = 'Videos';
    /**
     * 模板页列表
     */
    public function index()
    {
        $this->title = '视频管理';
        $get = $this->request->get();
        $db = Db::name($this->table)->where(['is_deleted' => '0']);
        foreach (['name'] as $key) {
            (isset($get[$key]) && $get[$key] !== '') && $db->whereLike($key, "%{$get[$key]}%");
        }
        if (isset($get['date']) && $get['date'] !== '') {
            list($start, $end) = explode('-', str_replace(' ', '', $get['date']));
            $db->whereBetween('create_time', ["{$start} 00:00:00", "{$end} 23:59:59"]);
        }
        return parent::_list($db);
    }

    // 添加
    public function add()
    {
        $this->_form($this->table, 'form');
    }

    // 编辑
    public function edit()
    {
        $this->_form($this->table, 'form');
    }

    // 禁用
    public function forbid()
    {
        $this->_save($this->table, ['status' => '0']);
    }

    // 启用
    public function resume()
    {
        $this->_save($this->table, ['status' => '1']);
    }

    // 删除
    public function remove()
    {
        $this->_delete($this->table);
    }




}
